using AuthCenter_HuangJingtao.Infrastructure;
using AuthCenter_HuangJingtao.Infrastructure.Implements;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using Microsoft.EntityFrameworkCore;
using System.Reflection;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();


builder.Services.AddMediatR(c=>c.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
builder.Services.AddScoped(typeof(IBaseReponsitory<>), typeof(BaseReponsitory<>));

builder.Services.AddDbContext<DbdataContext>(options =>
{
    options.UseMySql(builder.Configuration.GetConnectionString("Con"), new MySqlServerVersion(new Version(8, 0, 3)));
});
var app = builder.Build();

app.UseCors(c => c.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
 
}
   app.UseSwagger();
    app.UseSwaggerUI();
app.UseAuthorization();

app.MapControllers();

app.Run();
